#include <stdio.h>

int findComplement(int num)
{
    int start = 1;
    while (num >= start)
    {
        start <<= 1;//start比num高一位，例如num = 101，start = 1000
    }
    return (start - 1 - num);//start-1是num与其互补的和，例如num = 101，和 = start - 1 = 1000 - 1 = 111
}

int main()
{
    int num = 3;
    printf("%d\n",findComplement(num));
    return 0;
}